package com.wt.admin.service;

import com.wt.admin.config.aspect.LogAspect;
import com.wt.admin.service.ai.AgentsProxyService;
import com.wt.admin.service.ai.ChatProxyService;
import com.wt.admin.service.ai.KnowledgeProxyService;
import com.wt.admin.service.file.FileService;
import com.wt.admin.service.image.ImageProxyService;
import com.wt.admin.service.language.LanguageProxyService;
import com.wt.admin.service.sys.SysSettingService;
import jakarta.annotation.Resource;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Service;

import java.util.concurrent.Executor;

@Service
public class InitService implements ApplicationListener<ApplicationReadyEvent> {

    @Resource
    private LanguageProxyService languageProxyService;
    @Resource
    private ImageProxyService imageProxyService;
    @Resource
    private Executor publicThread;
    @Resource
    private AgentsProxyService agentsProxyService;
    @Resource
    KnowledgeProxyService knowledgeProxyService;
    @Resource
    private LogAspect logAspects;
    @Resource
    private FileService fileService;
    @Resource
    private SysSettingService sysSettingService;

    @Override
    public void onApplicationEvent(ApplicationReadyEvent event) {
        logAspects.init();
        fileService.init();
        sysSettingService.init();
        publicThread.execute(() ->imageProxyService.init());
        publicThread.execute(() ->agentsProxyService.init());
        publicThread.execute(() ->knowledgeProxyService.init());
    }
}
